using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace FE
{
    public class Weapon : Holdable
    {

        public enum WeaponType
        {
            Sword,
            Lance,
            Axe,
            Anima,
            Light,
            Dark,
            Neutral
        }

        public enum WeaponLevel
        {            
            S = 5,
            A = 4,
            B = 3,
            C = 2,
            D = 1,
            E = 0
        }

        protected WeaponType Type;
        protected WeaponLevel Level;
        protected int Might;
        protected int weight;
        protected int hit;
        protected int critical, Durability;
        protected Point range;

        public Point Range
        {
            get { return range; }
        }
        public int Weight
        {
            get { return weight; }
        }

        public int Critical
        {
            get { return critical; }
        }

        public bool IsInRange(Point one, Point two)
        {
            return GameMath.InRangeOf(one, two, range);
        }
        public bool UsesMagic ()
        {
            return Type == WeaponType.Anima || Type == WeaponType.Light || Type == WeaponType.Dark;
        }
        public bool UsesStrength ()
        {
            return Type == WeaponType.Sword || Type == WeaponType.Lance || Type == WeaponType.Axe || Type == WeaponType.Neutral;
        }
        public int GetHitRate (Weapon target)
        {
            if (Type == WeaponType.Sword && target.Type == WeaponType.Axe)
                return hit + 15;
            else if (Type == WeaponType.Axe && target.Type == WeaponType.Lance)
                return hit + 15;
            else if (Type == WeaponType.Lance && target.Type == WeaponType.Sword)
                return hit + 15;
            else if (Type == WeaponType.Anima && target.Type == WeaponType.Light)
                return hit + 15;
            else if (Type == WeaponType.Light && target.Type == WeaponType.Dark)
                return hit + 15;
            else if (Type == WeaponType.Dark && target.Type == WeaponType.Anima)
                return hit + 15;
            else if (Type == WeaponType.Axe && target.Type == WeaponType.Sword)
                return hit - 15;
            else if (Type == WeaponType.Lance && target.Type == WeaponType.Lance)
                return hit - 15;
            else if (Type == WeaponType.Sword && target.Type == WeaponType.Axe)
                return hit - 15;
            else if (Type == WeaponType.Light && target.Type == WeaponType.Anima)
                return hit - 15;
            else if (Type == WeaponType.Dark && target.Type == WeaponType.Light)
                return hit - 15;
            else if (Type == WeaponType.Anima && target.Type == WeaponType.Dark)
                return hit - 15;
            else
                return hit;
        }
        //Weapon triangle
        //Effective weapon might = (Might + Weapon Triangle advantage)*3 if weapon is
        //effective against target
        public int GetEffectiveMight (Weapon target)
        {
            if (Type == WeaponType.Sword && target.Type == WeaponType.Axe)
                return Might + 1;
            else if (Type == WeaponType.Axe && target.Type == WeaponType.Lance)
                return Might + 1;
            else if (Type == WeaponType.Lance && target.Type == WeaponType.Sword)
                return Might + 1;
            else if (Type == WeaponType.Anima && target.Type == WeaponType.Light)
                return Might + 1;
            else if (Type == WeaponType.Light && target.Type == WeaponType.Dark)
                return Might + 1;
            else if (Type == WeaponType.Dark && target.Type == WeaponType.Anima)
                return Might + 1;
            else if (Type == WeaponType.Axe && target.Type == WeaponType.Sword)
                return Might - 1;
            else if (Type == WeaponType.Lance && target.Type == WeaponType.Lance)
                return Might - 1;
            else if (Type == WeaponType.Sword && target.Type == WeaponType.Axe)
                return Might - 1;
            else if (Type == WeaponType.Light && target.Type == WeaponType.Anima)
                return Might - 1;
            else if (Type == WeaponType.Dark && target.Type == WeaponType.Light)
                return Might - 1;
            else if (Type == WeaponType.Anima && target.Type == WeaponType.Dark)
                return Might - 1;
            else
                return Might;
        }
    }
}
